Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snappier container healthchecks #856

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tanasegabriel
Copy link

@tanasegabriel tanasegabriel commented Jan 6, 2025

Description

Allowing the healthceck to mark the container as healthy shortly after lighttpd has started, rather than always waiting ~30 seconds.

Before:

~ time docker compose up -d homer --wait
[+] Running 1/1
 ✔ Container homer  Healthy                                                                                       30.8s
docker compose up -d homer --wait  0.41s user 0.13s system 1% cpu 31.103 total

After:

~ time docker compose up -d homer --wait
[+] Running 1/1
 ✔ Container homer  Healthy                                                                                        1.9s
docker compose up -d homer --wait  0.34s user 0.07s system 18% cpu 2.199 total

Reference: https://docs.docker.com/reference/dockerfile/#healthcheck

Tested with:

Client: Docker Engine - Community
 Version:           27.4.1
 API version:       1.47
 Go version:        go1.22.10
 Git commit:        b9d17ea
 Built:             Tue Dec 17 15:46:31 2024
 OS/Arch:           linux/arm64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.4.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.10
  Git commit:       c710b88
  Built:            Tue Dec 17 15:46:31 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.7.24
  GitCommit:        88bf19b2105c8b17560993bee28a01ddc2f97182
 runc:
  Version:          1.2.2
  GitCommit:        v1.2.2-0-g7cb3632
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker Compose version v2.32.1

This implies a minimum compose version of v2.20.2

interval, timeout, start_period, and start_interval are specified as durations. Introduced in Docker Compose version 2.20.2

I'm unsure if this might break older Docker versions, Synology is known for not keeping on top of updates for example 😓

Fixes # (issue)
#855

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I've read & comply with the contributing guidelines
  • I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
  • I have made corresponding changes to the documentation (README.md).
  • I've checked my modifications for any breaking changes, especially in the config.yml file

@tanasegabriel tanasegabriel force-pushed the gabriel/snappier_healthchecks branch from 37f40c0 to 4da2bef Compare January 6, 2025 22:53
@@ -37,7 +37,7 @@ COPY --from=build-stage --chown=${UID}:${GID} /app/dist/assets /www/default-asse

USER ${UID}:${GID}

HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
HEALTHCHECK --start-period=10s --start-interval=1s --interval=30s --timeout=5s --retries=3 \
Copy link
Author

@tanasegabriel tanasegabriel Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative here would be to drop the start-interval arg (this is the one that was relatively recently introduced) and simply keep start-period=10s with the default interval:

--start-period=DURATION (default: 0s)
--start-interval=DURATION (default: 5s)

That might be less disruptive for older Docker versions. @bastienwirtz wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant